package com.zsk.gen;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

public class GenUtil {

    public static boolean isEmpty(String str) {
        return str == null || "".equals(str);
    }

    public static boolean isNotEmpty(String str) {
        return str != null || !"".equals(str);
    }

    /**
     * 驼峰转下划线
     * 
     * @param name
     * @return
     */
    public static String transHumpToUnderline(String name) {
        return null;
    }

    /**
     * 下划线转驼峰
     * 
     * @param name
     * @return
     */
    public static String transUnderlineToHump(String name, boolean firstCharUpper) {
        int len = name.length();
        int i = name.indexOf('_');
        while (i > 0 && i != len - 1) {
            name = name.substring(0, i) + name.substring(i + 1, i + 2).toUpperCase() + name.substring(i + 2);
            i = name.indexOf('_');
        }
        if (firstCharUpper) {
            return name.substring(0, 1).toUpperCase() + name.substring(1);
        }
        return name;

    }

    public static String getYmd() {
        return new SimpleDateFormat("yyyy/MM/dd").format(new Date()).toString();
    }

    public static boolean fileExist(String path) {
        if (new File(path).isFile()) {
            return true;
        }
        return false;
    }

}
